package com.ibm.risk.irmp.base;

import com.ibm.risk.irmp.base.file.service.FileStoreService;
import com.ibm.risk.irmp.base.file.service.impl.LocalFileStoreServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BaseAppConfig {
    @Bean
    public FileStoreService fileStoreService(@Value("${app.irmp.base.filestore.impl:}") String fileStoreImpl) throws Exception {
        if (fileStoreImpl == null || fileStoreImpl.isEmpty()) {
            return new LocalFileStoreServiceImpl();
        }
        return (FileStoreService) Class.forName(fileStoreImpl).getConstructor().newInstance();
    }
}
